

package com.hexinfo.dmpro.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.http.ResponseEntity;
import com.hexinfo.dmpro.admin.model.SysJob;
import com.hexinfo.dmpro.admin.service.SysJobService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 岗位表
 *
 * @author zhouax
 * @date 2023-08-09 14:06:39
 */
@RestController
@AllArgsConstructor
@RequestMapping("/sysjob" )
@Api(value = "sysjob", tags = "岗位表管理")
public class SysJobController {

    private final  SysJobService sysJobService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param sysJob 岗位表
     * WrapperEnhancer.like(sysJob); //自动拼接存在值sql的方法
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    public ResponseEntity<Object> getSysJobPage(Page page, SysJob sysJob) {
        return ResponseEntity.ok(sysJobService.queryList(page,sysJob));
    }


    /**
     * 通过id查询岗位表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    public ResponseEntity<Object> getById(@PathVariable("id" ) Long id) {
        return ResponseEntity.ok(sysJobService.getById(id));
    }

    /**
     * 新增岗位表
     * @param sysJob 岗位表
     * @return R
     */
    @ApiOperation(value = "新增岗位表", notes = "新增岗位表")
    @PostMapping
    public ResponseEntity<Object> save(@RequestBody SysJob sysJob) {
        return ResponseEntity.ok(sysJobService.save(sysJob));
    }

    /**
     * 修改岗位表
     * @param sysJob 岗位表
     * @return R
     */
    @ApiOperation(value = "修改岗位表", notes = "修改岗位表")
    @PutMapping
    public ResponseEntity<Object> updateById(@RequestBody SysJob sysJob) {
        return ResponseEntity.ok(sysJobService.updateById(sysJob));
    }

    /**
     * 通过id删除岗位表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除岗位表", notes = "通过id删除岗位表")
    @DeleteMapping("/{id}" )
    public ResponseEntity<Object> removeById(@PathVariable Long id) {
        return ResponseEntity.ok(sysJobService.removeById(id));
    }

}
